<?php


		$text = @file_get_contents('http://sergey-mavrodi.com/kurs.php');
		$text = substr($text, strpos($text, "</table>"));
		$text = substr($text, strpos($text, "<tr align=\"center\">"));
		$text = str_replace("\t", "", $text);
		$text = str_replace("<a name='current_day'></a>", "", $text);
		$text = str_replace(' bgcolor="#FFCC99"', "", $text);
		$text = str_replace(' bgcolor="#FFFFCC"', "", $text);
		$text = str_replace(' bgcolor="#EEEEEE"', "", $text);
		$text = str_replace(' bgcolor="#FFA602"', "", $text);
		$text = str_replace(' style="width:40px;"', "", $text);
		$text = str_replace(' style="width:35px;"', "", $text);
		$text = str_replace(' style="width:41px;"', "", $text);
		$text = str_replace(' style="width:50px;"', "", $text);
		$text = str_replace(' style="width:42px;"', "", $text);
		$text = str_replace(' style="width:51px;"', "", $text);
		$text = str_replace('<b>', "", $text);
		$text = str_replace('</b>', "", $text);
		$text = str_replace('<td>', "", $text);
		$text = str_replace('</td>', "", $text);
		$text = str_replace('</tr>', "", $text);
		$text = str_replace('<br />', ".", $text);
		$text = str_replace('Чт.', "", $text);
		$text = str_replace('Вт.', "", $text);
		$text = str_replace('<span style=\'font-size:14px\'>ном.</span>', "", $text);
		$arr_text = explode("\n", $text);
		$begin = true;
		$percent = 20;
		foreach($arr_text as $row)
		{
			$row = trim($row);
			if($row == '') continue;
			if(substr($row, 0, 8) == '</tbody>') continue;
			if(substr($row, 0, 3) == '<tr')
			{
				$begin = true;
				continue;
			}
			if($begin)
			{
				list($d, $m, $y) = explode(".", $row);
				$date = dateToDb($y."-".$m.'-'.$d);
				$begin = false;
				$percent = 20;
				continue;
			}
			list($buy, $sell) = explode("<hr>", $row);
			$buy = trim(str_replace(",", "", $buy));
			$sell = trim(str_replace(",", "", $sell));
			$arr = array(
				'date' => $date,
				'percent' => $percent,
				'buy' => $buy,
				'sell' => $sell
			);
			$percent += 10;
			if($percent == 70) 
			{
				$percent = 45;
			}
			echo "<pre>".print_r($arr, true)."</pre>";
		}